<!-- 修改用户上下级 -->
<template>
    <div>
        <div class="table-page-search-wrapper">
            <a-form :label-col="{ span: 5 }" :wrapper-col="{ span: 10 }">
                <a-form-item label="下级手机号">
                    <a-input v-model="sonUserPhone" placeholder="请输入下级手机号" allow-clear></a-input>
                </a-form-item>
                <a-form-item label="上级手机号">
                    <a-input v-model="parentUserPhone" placeholder="请输入上级手机号" allow-clear></a-input>
                </a-form-item>
                <a-form-item  v-bind="formItemLayoutWithOutLabel">
                    <a-button :loading="loading" type="primary" @click="submit">确定</a-button>
                </a-form-item>
            </a-form>
        </div>
    </div>
</template>

<script>
import { updateUserRelation } from '@/api/power';
import { queryBrand }  from '@/api/brand';
export default {
    data () {
        return {
            brandId: this.global.brandId,
            sonUserPhone: '',
            parentUserPhone: '',
            formItemLayoutWithOutLabel: {
                wrapperCol: {
                    xs: { span: 24, offset: 0 },
                    sm: { span: 20, offset: 5 },
                },
            },
            loading: false,
        };
    },
    created(){
    },
    methods: {
        submit(){
            let _this = this
            _this.loading = true
            if(_this.sonUserPhone == ''){
                _this.$message.warning('请输入下级手机号')
                return
            }
            if(_this.parentUserPhone == ''){
                _this.$message.warning('请输入上级手机号')
                return
            }
            const params = {
                'brandId':_this.brandId,
                'sonUserPhone':_this.sonUserPhone,
                'parentUserPhone':_this.parentUserPhone,
            }
            updateUserRelation(params)
            .then(res=>{
                _this.loading = false
                if(res.success){
                    _this.$notification['success']({
                        message: '提示',
                        description: '修改成功',
                        duration: 8,
                    })
                }else{
                    _this.$notification['error']({
                        message: '提示',
                        description: res.errMessage,
                        duration: 8,
                    })
                }
            })
        },
    }
}

</script>
<style scoped>

</style>